package com.stb.llh.service;

import com.stb.llh.dao.EmotionDao;
import com.stb.llh.entity.Emotion;
import com.stb.llh.util.TimesGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author Lee
 * @Date 2021/11/3
 * @Description
 */

@Repository
@Transactional
public class EmotionService {

    @Autowired
    private EmotionDao emotionDao;

    public boolean insertEmotion(String username, String con, double rate){
        Emotion emotion = emotionDao.save(new Emotion(username, con, rate, TimesGenerator.time()));
        return emotion != null;



    }

    public List<Emotion> getEmotions(){
        return emotionDao.findAll();
    }

}
